package ch.zbw.timeline.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.Data;

/**
 * Domain class for an entry
 */
@Entity
@SequenceGenerator(name = "id_entry", initialValue = 1, allocationSize = 1)
@Table(name = "entry")
@Data
public class Entry implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_entry", nullable = false)
	private int id;

	@Column(name = "fk_daily_presence", nullable = false)
	private int dailyPresenceFk;

	@Column(name = "fk_allocation", nullable = false)
	private int allocationFk;

	@Column(name = "fk_overtime_pool", nullable = true)
	private Integer overtimePoolFk;

	@Column(name = "duration", nullable = false)
	private double duration;

	@Column(name = "comment", nullable = true)
	private String comment;

	@Transient
	private Allocation allocation;

	public Entry() {
	}

	public Entry(int dailyPresenceFk, int allocationFk, Integer overtimePoolFk,
			double duration, String comment) {
		this.dailyPresenceFk = dailyPresenceFk;
		this.allocationFk = allocationFk;
		this.overtimePoolFk = overtimePoolFk;
		this.duration = duration;
		this.comment = comment;
	}
}
